/*------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 *  $LastChangedRevision::                                          $
 *  $LastChangedBy::                                                $
 *  $LastChangedDate::                                              $
 */

package com.ncr.nep.dashboardcore.mvp.client;

import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Singleton;

/**
 * Extension of {@link AbstractGinModule} that provides additional binding
 * methods for {@link Presenter} and {@link View} types.
 * 
 * @author rb250096
 * @version $Revision$
 */
public abstract class PresenterGinModule extends AbstractGinModule {

    /**
     * Binds a {@link Presenter} type to its corresponding {@link View} and
     * that view's implementation.
     *
     *
     * @param presenterType The type of presenter to bind.
     * @param viewType The type of {@link View} associated with the presenter.
     * @param viewImplType An implementation of viewType that should be
     *                     injected for instances of viewType.
     *
     * @param <P> The presenter type.
     * @param <V> The view type.
     * @param <T> The type of view implementation.
     */
    public <P extends Presenter<?>, V extends View, T extends V> void bindPresenter(
            Class<P> presenterType,
            Class<V> viewType,
            Class<T> viewImplType) {
        this.bind(presenterType);
        this.bind(viewType).to(viewImplType);
    }

    /**
     * Binds a singleton {@link Presenter} type to its corresponding
     * {@link View} and that view's implementation.
     *
     * @param presenterType The type of presenter to bind.
     * @param viewType The type of {@link View} associated with the presenter.
     * @param viewImplType An implementation of viewType that should be
     *                     injected for instances of viewType.
     * @param <P> The presenter type.
     * @param <V> The view type.
     * @param <T> The type of view implementation.
     */
    public <P extends Presenter<?>, V extends View, T extends V> void bindSingletonPresenter(
            Class<P> presenterType,
            Class<V> viewType,
            Class<T> viewImplType) {
        this.bind(presenterType).in(Singleton.class);
        this.bind(viewType).to(viewImplType).in(Singleton.class);
    }
}
